<template>
  <div class="project-base">
    <!--  其他企业  -->
    <top-menu :active="active" ref="enterpriseBottom" @upActiveStep="upActiveStep" :enterpriseName="enterpriseName"
              @clearEnterpriseMenuName="enterpriseName=''"></top-menu>

<!--    :enterprise-id="enterpriseId"-->
    <fuel-use v-if="active==='step0'" :enterprise-id="enterpriseId"/>
    <fugitive-emissions v-if="active==='step1'" :enterprise-id="enterpriseId"/>
    <purchased-energy v-if="active==='step2'" :enterprise-id="enterpriseId"/>
    <material-inputs v-if="active==='step3'" :enterprise-id="enterpriseId"/>
    <logistics v-if="active==='step4'" :enterprise-id="enterpriseId"/>
    <travel v-if="active==='step5'" :enterprise-id="enterpriseId"/>
    <commuting v-if="active==='step6'" :enterprise-id="enterpriseId"/>
    <waste-water v-if="active==='step7'" :enterprise-id="enterpriseId"/>
    <apportionment v-if="active==='step8'" :enterprise-id="enterpriseId"/>
    <product-apportionment v-if="active==='step9'" :enterprise-id="enterpriseId"/>
    <result-year v-if="active==='step10'" :enterprise-id="enterpriseId"/>


  </div>
</template>

<script>
import TopMenu from '../common/topMenu';
import FuelUse from './fuelUse';
import FugitiveEmissions from './fugitiveEmissions';
import PurchasedEnergy from './purchasedEnergy';
import MaterialInputs from './materialInputs';
import Logistics from './logistics';
import Travel from './travel';
import Commuting from './commuting';
import WasteWater from './wasteWater';
import Apportionment from './apportionment';
import ProductApportionment from './productApportionment';
import ResultYear from './resultYear';

import {listEnterprise, getEnterprise, addEnterprise, updateEnterprise} from "@/api/enterprise/enterprise";

export default {
  name: 'photovoltaic',
  components: {

    TopMenu, FuelUse, FugitiveEmissions, PurchasedEnergy, MaterialInputs, Logistics,
    Travel, Commuting, WasteWater, Apportionment, ProductApportionment, ResultYear

  },
  data() {
    return {
      data: null,
      enterpriseType: null,
      enterpriseName: '',
      enterpriseId: '0',
      active: "step0",//步骤
    }
  },
  created() {
    let {enterpriseId, enterpriseType} = this.$route.params;
    this.enterpriseType = enterpriseType;
    this.enterpriseId = enterpriseId;
    this.selectDataFun()
  },
  methods: {
    selectDataFun() {
      getEnterprise(this.enterpriseId).then(res => {
        if (res.data) {
          this.data = res.data;
          this.enterpriseName = res.data.enterpriseName;
        }
      });
    },
    showLoading() {
      this.loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
    },
    hideLoading() {
      this.loading.close();
    },
    upActiveStep(data) {
      this.submitFromData(this.active, data);
    },
    //提交每一步数据
    submitFromData(thatActive, nextActive) {
      let _that = this;
      _that.showLoading();
      // if (thatActive === "step0") { //项目概况
      //   _that.$refs.projectOverview.subMitAProjectFromData().then(res=>{
      //     _that.hideLoading();
      //     res.nextActive = nextActive;
      //     _that.setShowEnterpriseId(res.enterpriseId);
      //     _that.getFromData(res);
      //   }).catch(err=>{
      //     _that.hideLoading();
      //   });
      // }
      // if (thatActive === 'step1') { //负荷测算
      //   _that.$refs.projectLoadModelStep.submitFromData().then(res=>{
      //     _that.hideLoading();
      //     res.nextActive = nextActive;
      //     _that.getFromData(res);
      //   }).catch(err=>{
      //     _that.hideLoading();
      //   });
      // }
      // if (thatActive === 'step12') { //光伏处理预测
      //   _that.hideLoading();
      //   _that.getFromData({nextActive});
      //   return
      //   // _that.$refs.projectPvOutPutPredictionStep.submitFromData().then(res=>{
      //   //   _that.hideLoading();
      //   //   res.nextActive = nextActive;
      //   //   _that.getFromData(res);
      //   // }).catch(err=>{
      //   //   _that.hideLoading();
      //   // });
      // }
      // if (thatActive === 'step5') { //设计参数
      //   // _that.hideLoading();
      //   // _that.getFromData({nextActive});
      //   // return
      //   _that.$refs.projectDesign.submitFromData().then(res=>{
      //     _that.hideLoading();
      //     res.nextActive = nextActive;
      //     _that.getFromData(res);
      //   }).catch(err=>{
      //     _that.hideLoading();
      //   });
      // }
      // if (thatActive === 'step6') { //总图优化
      //   _that.$refs.projectGeneralPlanOptimizationStep.submitFromData().then(res=>{
      //     _that.hideLoading();
      //     res.nextActive = nextActive;
      //     _that.getFromData(res);
      //   }).catch(err=>{
      //     _that.hideLoading();
      //   });
      // }
      // if (thatActive === 'step7') { //容量优化
      //   _that.$refs.projectTechnicalRouteStep.submitFromData().then(res=>{
      //     _that.hideLoading();
      //     res.nextActive = nextActive;
      //     _that.getFromData(res);
      //   }).catch(err=>{
      //     _that.hideLoading();
      //   });
      // }
      // if (thatActive === 'step8') { //方案优化
      //   _that.$refs.projectSchemeOptimizationStep.submitFromData().then(res=>{
      //     _that.hideLoading();
      //     res.nextActive = nextActive;
      //     _that.getFromData(res);
      //   }).catch(err=>{
      //     _that.hideLoading();
      //   });
      // }
      // if (thatActive === 'step10') { //报告生成
      //   _that.hideLoading();
      //   _that.getFromData({nextActive});
      //   return
      // }
      _that.hideLoading();
      _that.getFromData({nextActive});

    },
    // setShowEnterpriseId(id){ //传递项目id  用于新项目
    //   if(this.enterpriseId===id){
    //     return
    //   }
    //   this.enterpriseId = id;
    //   this.isUpdate = true;
    // },
    //获取下一步数据
    getFromData(data) {
      this.active = data.nextActive;
    },
  }
}
</script>

<style scoped>

</style>
